package models.re.realData;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToOne;

import models.aaa.Asset;
import models.aaa.Node;
import models.re.IItem;
import models.re.IRelation;
import models.re.simulatedData.Relation;
import models.re.simulatedData.Relation.Type;

@Entity
public class AssetRelation extends Node implements IRelation {
	
	private Type type = Type.EMPTY;
	
	private Integer count = 0;
	
	@ManyToOne(fetch=FetchType.LAZY)
	private Asset source = null;
	
	@ManyToOne(fetch=FetchType.LAZY)
	private Asset target = null;
	
	AssetRelation() {
		
	}
	
	AssetRelation(IItem source, IItem target, String type) {
		this.type=Relation.str2Relation(type);
        this.source=(Asset)source;
        this.target=(Asset)target;       
        this.increment();
	}

	@Override
	public Type getType() {
		// TODO Auto-generated method stub
		return this.type;
	}

	@Override
	public void increment() {
		// TODO Auto-generated method stub
		if(this.type==Type.VISITE) this.count++;
	}

	@Override
	public IItem getSource() {
		// TODO Auto-generated method stub
		return this.source;
	}

	@Override
	public IItem getTarget() {
		// TODO Auto-generated method stub
		return this.target;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return this.count;
	}

}
